package com.ecloud.trianglerectanglelabelview;

import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.agp.components.Attr;
import ohos.agp.components.AttrSet;
import ohos.app.Context;
import org.junit.Test;
import org.junit.runner.manipulation.Ordering;

import java.util.Optional;

import static org.junit.Assert.*;

public class ExampleOhosTest {
    Context context = MyApplication.getContexts();
    @Test
    public void testBundleName() {
        final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
        assertEquals("com.ecloud.trianglerectanglelabelview", actualBundleName);
    }

    @Test
    public void testColor(){
        TriangleRectangleLabelView triangleRectangleLabelView = new TriangleRectangleLabelView(context, new AttrSet() {
            @Override
            public Optional<String> getStyle() {
                return Optional.empty();
            }

            @Override
            public int getLength() {
                return 0;
            }

            @Override
            public Optional<Attr> getAttr(int i) {
                return Optional.empty();
            }

            @Override
            public Optional<Attr> getAttr(String s) {
                return Optional.empty();
            }
        });
        assertNotNull(triangleRectangleLabelView);
    }

    @Test
    public void testTriangleRectangleLabelViewInstance(){
        TriangleRectangleLabelView view  = new TriangleRectangleLabelView(context, new AttrSet() {
            @Override
            public Optional<String> getStyle() {
                return Optional.empty();
            }

            @Override
            public int getLength() {
                return 1;
            }

            @Override
            public Optional<Attr> getAttr(int i) {
                return Optional.empty();
            }

            @Override
            public Optional<Attr> getAttr(String s) {
                return Optional.empty();
            }
        });
        assertNotNull(view);

    }

    @Test
    public void testOnEstimateSize(){
        TriangleRectangleLabelView view  = new TriangleRectangleLabelView(context, new AttrSet() {
            @Override
            public Optional<String> getStyle() {
                return Optional.empty();
            }

            @Override
            public int getLength() {
                return 10;
            }

            @Override
            public Optional<Attr> getAttr(int i) {
                return Optional.empty();
            }

            @Override
            public Optional<Attr> getAttr(String s) {
                return Optional.empty();
            }
        },"");
        boolean flga = view.onEstimateSize(0,1);
        assertEquals(flga,true);

    }

    @Test
    public void testOnEstimateSizeMoreParams(){
        TriangleRectangleLabelView view  = new TriangleRectangleLabelView(context, new AttrSet() {
            @Override
            public Optional<String> getStyle() {
                return Optional.empty();
            }

            @Override
            public int getLength() {
                return 10;
            }

            @Override
            public Optional<Attr> getAttr(int i) {
                return Optional.empty();
            }

            @Override
            public Optional<Attr> getAttr(String s) {
                return Optional.empty();
            }
        },"");

        boolean flga = view.onEstimateSize(1,1);
        assertEquals(flga,true);

    }



}